{include file="Public:header" /}
<div class="row">
    <div class="col-sm-12">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5 style="line-height: 30px;font-weight: bold;">权限列表</h5>
                <a href="{:url('Auth/ruleAdd')}" class="btn btn-sm btn-info" style="margin-left: 10px;">添加权限</a>
            </div>
            <div class="ibox-content">
                <table class="table table-bordered">
                    <thead>
                        <tr>
                            <th>名称</th>
                            <th>权限</th>
                            <th>条件</th>
                            <th style="text-align: center;">操作</th>
                        </tr>
                    </thead>
                    <tbody>
                    {volist name="list" id="vo"}
                        <tr>
                            <td>{$vo._name}</td>
                            <td>{$vo.name}</td>
                            <td>
                                {if condition="$vo.condition eq ''"}
                                    无
                                {else/}
                                    {$vo.condition}
                                {/if}
                            </td>
                            <td style="text-align: center">
                                <a href="{:url('Auth/ruleAdd',array('pid' => $vo.id))}" class="edit btn btn-sm btn-info">添加子权限</a>
                                <a href="{:url('Auth/ruleEdit',array('rid' => $vo.id))}" class="edit btn btn-sm btn-info">编辑</a>
                                {if condition="$vo.status eq 1"}
                                <a href="javascript:;" class="del btn btn-sm btn-info" sid="{$vo.id}">禁用</a>
                                {else/}
                                <a href="javascript:;" class="del btn btn-sm btn-info" sid="{$vo.id}">启用</a>
                                {/if}
                                <a href="{:url('Auth/ruleDel',array('rid' => $vo.id))}" class="edit btn btn-sm btn-info">删除</a>
                            </td>
                        </tr>
                    {/volist}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
{include file="Public:footer" /}
<script>
    $(function(){
        //删除
        $('.del').click(function(){
            var sid = $(this).attr('sid');
            $.get("{:url('/index/Index/checkGoodsExist/sid/"+sid+"')}",function(data){
                if(data.code == 0)
                {
                    layer.msg(data.msg);
                }else{
                    layer.msg('确定要删除该供应商？',{
                        time:0,
                        btn:['确定','取消'],
                        yes:function (index) {
                            layer.close(index);
                            $.get("{:url('/index/Index/supplyDel/sid/"+ sid +"')}",function(data){
                                if(data.code == 1)
                                {
                                    layer.msg(data.msg);
                                    setTimeout(function(){
                                        window.location.href = data.url;
                                    },200);
                                }else{
                                    layer.msg(data.msg);
                                }
                            },'json');
                        }
                    });
                }
            },'json');
        });
    });

</script>